package com.xbongbong.sso.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 来源枚举
 */
@Getter
public enum SourceEnum {
    /**
     *
     */
    DINGDING("ding","钉钉"),
    QIWEI("wq","企微"),
    FEISHU("fs","飞书"),
    XBB("xbb","销帮帮独立版"),
    UNKNOWN("unknown","未知"),
    ;


    private String alias;

    private String name;

    SourceEnum(String alias, String name) {
        this.alias = alias;
        this.name = name;
    }

    /**
     * 根据alias获取枚举
     * @return
     */
    public static SourceEnum getByAlias(String alias) {
        if (alias == null) {
            return UNKNOWN;
        }
        for (SourceEnum cache : values()) {
            if (Objects.equals(cache.getAlias(), alias)) {
                return cache;
            }
        }
        return UNKNOWN;
    }
}
